#ifndef _H_APP_
#define _H_APP_
#include "define.h"
#define P_APP_BUZZ_PORT GPIOB
#define P_APP_BUZZ_PIN 1

#define P_APP_LED_PORT GPIOB
#define P_APP_LED_PIN 0

#define P_APP_HUMANDET_PORT GPIOA
#define P_APP_HUMANDET_PIN 1

#define APP_RUNMODE_NUM 3
#define APP_RUNMODE_IDLE 0
#define APP_RUNMODE_MANUAL 1
#define APP_RUNMODE_AUTO 2

#define APP_SETMODE_IDLE 0
#define APP_SETMODE_TIMER 1
#define APP_SETTIMER_DIGSNUM 2

#define APP_BUZZTIMER_TIME 500

typedef struct{
	U8 led;
	U8 curtain;
	U8 beep;
	U8 fan;
	U8 temp;
	U8 himi;
	U16 yw;//m2
	U16 CO;//m7
	U16 airquality;//m135
	U16 gz;//gz
}STRAppAttrType;
typedef struct{
	U8 state;
	U16 timer;


	U16 reporttimer;
	
	U8 wificonnected;
	U16 wificonnecttimer;
	U8 wifirssi;
	U8 reportlimtimer;
	U8 connecttimes;
	STRAppAttrType attrs;
	U8 attrready;
	
}STRAppType;

extern STRAppType g_app_stRegs;

#define APP_DATA_OFFSET_TEMP 0
#define APP_DATA_OFFSET_LEVEL 1
#define APP_DATA_OFFSET_MODE 2
#define APP_DATA_OFFSET_THRES 3
#define APP_DATA_OFFSET_HIMIDITY 4
#define APP_DATA_OFFSET_TIMER 5
extern void fnApp_Init(void);
extern void fnApp_RealTime(void);
extern void fnApp_HandlActionData(U8 *data, U16 len);
extern void fnApp_SetMode(U8 mode);
extern void fnApp_SetLevel(U8 level);
extern void fnApp_SetTemp(U8 tempthes);
extern void fnApp_SetTimer(U8 timer);

extern U8 fnApp_CheckReport(void);
extern void fnApp_GetReport(U8 *data, U32 *len);
extern void fnApp_WFCallBack(U8 status);
extern void fnApp_WFRSSI(U8 rssi);
extern void fnApp_SetValues(float temp, float humidity,float brightness, float smoke);
extern void fnApp_SetStatus(U8 warning, U8 buzz, U8 led, U8 fan);
extern void fnApp_BuzzCon(U8 buzz);
extern void fnApp_WarningCon(U16 value);
#endif
